The guide rails of an elevator, such as the car guide rails or counterweight guide rails, are generally fixed in position by stacking elongated guide rails to be supported by each other in the vertical direction and by supporting them in the lateral direction to be immovable on the building with guide rail brackets, which aim to permit longitudinal movement of a guide rail in relation to the building. A guide rail must be able to move in relation to the building because the dimensional changes of a long guide rail line and of the building in relation to time are different. After the construction phase the drying of concrete, in particular, results in shrinking of the building, a consequence of which can be compression of the guide rail line into a curve if the guide rails of the guide rail line are not able to move in relation to the building. This relative movement is in prior art arranged to occur e.g. with sliding between a guide rail bracket rigidly fixed to the building and the guide rail. In these types of solutions the guide rail clamp of the guide rail bracket presses the guide rail against the base comprised in the guide rail bracket. A problem of this solution is that the thickness tolerances of the guide rails are large and the compression force exerted by the guide rail clamp on the guide rail might form to be too great, preventing sliding between the guide rail and the clamp. More specifically, when a thick point of the guide rail slides to the point of the guide rail clamp, the structure of the guide rail clamp does not always give way sufficiently and as a result of this it presses the guide rail against the base with too great a force. A consequence of this can be bulging of the guide rail line as the guide rails are compressed into a curve.